# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Doug Newgard <scimmia at archlinux dot info>

pkgname=notepadqq
pkgver=2.0.0beta
pkgrel=1
pkgdesc='Notepad++-like text editor for Linux'
arch=('loong64' 'x86_64')
url='https://notepadqq.com/'
license=('GPL3')
depends=('hicolor-icon-theme' 'qt5-svg' 'qt5-webengine' 'qt5-websockets' 'uchardet')
makedepends=('git' 'qt5-tools')
optdepends=('mathjax2: Math rendering')
options=('!emptydirs')
_commit=5317c21678e71687aaab56862339354e1ea07306
source=("git+https://github.com/notepadqq/notepadqq.git#commit=$_commit"
        "git+https://github.com/notepadqq/CodeMirror.git")
sha256sums=('SKIP'
            'SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g' | sed 's/\+//'
}

prepare() {
  cd $pkgname
  git config submodule.src/editor/libs/codemirror.url "$srcdir/CodeMirror"
  git submodule update --init

  # Unbundle MathJax
  sed -i 's|libs/MathJax/MathJax|../../mathjax2/MathJax|' src/editor/features/latex/latex.js
  sed -i '/MathJax/d' src/editor/Makefile
}

build() {
  cd $pkgname
  qmake-qt5 PREFIX=/usr LRELEASE=/usr/bin/lrelease notepadqq.pro
  make
}

package() {
  cd $pkgname
  make INSTALL_ROOT="$pkgdir" install
}
